package com.gyms.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.gyms.R;
import com.gyms.adapter.ComTabViewPagerAdapter;
import com.gyms.base.BaseActivity;
import com.gyms.constant.Constants;
import com.gyms.fragment.MyOrderFragment;
import com.gyms.manager.TitleManager;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 我的订单页面
 * ltx
 */

public class MyOrderActivity extends BaseActivity {
    private TabLayout mTlMyOrder;
    private ViewPager mVpMyOrder;

    private static final String S_ORDER_ALL="全部";
    private static final String S_ORDER_UN_COMPLETE="未完成";
    private static final String S_ORDER_COMPLETE="已完成";
    private static final String S_ORDER_REFUND="已退款";
    @Override
    protected void setTitleTheme() {
        mTheme = TitleManager.TitleTheme.White;
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_my_order;
    }

    @Override
    protected void initView() {
        setTitle("我的订单");
        mTlMyOrder= (TabLayout) findViewById(R.id.tl_my_order);
        mVpMyOrder= (ViewPager) findViewById(R.id.vp_my_order);
        setBack();
        initVpAdapter();
    }

    @Override
    protected void setListener() {

    }

    @Override
    protected void processLogic() {

    }

    /**
     * 初始化ViewPagerAdapter
     */

    private void initVpAdapter() {
        List<String> mStrTabTitles=new ArrayList<>(Arrays.asList(S_ORDER_ALL,S_ORDER_UN_COMPLETE,S_ORDER_COMPLETE,S_ORDER_REFUND));
        ArrayList<Fragment> mMyOrderFragment=new ArrayList<>();
        MyOrderFragment mAllOrderFragment=MyOrderFragment.newIntance(Constants.MY_ORDER_ALL);
        MyOrderFragment mUnCompleteFragment=MyOrderFragment.newIntance(Constants.MY_ORDER_UN_COMPLETE);
        MyOrderFragment mCompleteOrderFragment=MyOrderFragment.newIntance(Constants.MY_ORDER_COMPLETE);
        MyOrderFragment mRefundFragment=MyOrderFragment.newIntance(Constants.MY_ORDER_REFUND);
        mMyOrderFragment.add(mAllOrderFragment);
        mMyOrderFragment.add(mUnCompleteFragment);
        mMyOrderFragment.add(mCompleteOrderFragment);
        mMyOrderFragment.add(mRefundFragment);
        ComTabViewPagerAdapter mCommonPagerAdapter=new ComTabViewPagerAdapter(getSupportFragmentManager(),mMyOrderFragment,mStrTabTitles);
        mVpMyOrder.setAdapter(mCommonPagerAdapter);
        mTlMyOrder.setupWithViewPager(mVpMyOrder);
        mVpMyOrder.setCurrentItem(0);
        mVpMyOrder.setOffscreenPageLimit(3);
    }
}
